/*
 * 文件名：GenerateCode.java
 * 版权：Copyright by AltonSoftware
 * 描述：
 * 修改人：Administrator
 * 修改时间：2014年12月9日
 * 修改内容：
 */

package com.etc.common.util;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * 生成随机验证码
 * @author hunter
 * @version 2014年12月9日
 * @see GenerateCode
 * @param 
 * @since
 */

public class GenerateCode
{
    /**
     * 
     * Description: 生成6位随机数<br>
     * @return 
     * @see
     */
    public static String generateWord()
    {  
        String[] beforeShuffle = new String[] { "0","1","2", "3", "4", "5", "6", "7",  
            "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",  
                                                "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",  
                                                  "W", "X", "Y", "Z" };  
        List<String> list = Arrays.asList(beforeShuffle);
        //打乱排序
        Collections.shuffle(list);  
        StringBuilder sb = new StringBuilder();  
        for (int i = 0; i < list.size(); i++)
        {  
            sb.append(list.get(i));  
        }  
        String afterShuffle = sb.toString();  
       //更改下面两个数字可以去到不同位数的随机数哦
        String result = afterShuffle.substring(4, 10);  
        return result;  
    }
}
